//
// Created by REEJI2219 on 2024-09-29.
//
using namespace std;
typedef int ElemType;
class Node {
public:
    ElemType data;
    Node *next;
    ~Node() {
        next = nullptr;
    }
};
class CycilLinkList{
public:
    Node *head;
    CycilLinkList() {
        head = new Node();
        head->next = head;
    }

    /**
     * 是否为头节点
     * @param node 当前节点
     * @return
     */
    bool isTail(Node *node) {
        return node->next==head;
    }

    /**
     * 尾节点插入
     * @param data 数据
     */
    void appendNode(ElemType data) {
        Node *current = head;
        //不为头节点
        while (!isTail(current->next)) {
            current = current->next;
        }
        Node *node = new Node();
        node->data = data;
        current->next = node;
        node->next = head;
    }

}